﻿using System.Collections.Generic;

namespace MLog.Core {
    public class SubstituteLoggerFactory : ILoggerFactory {
        private readonly Queue<LoggerEvent> _eventQueue = new Queue<LoggerEvent>();

        public Queue<LoggerEvent> EventQueue {
            get { return _eventQueue; }
        }

        public ILogger GetLogger(string name) {
            var logger = new SubstituteLogger();
            logger.Name     = name;
            logger.Delegate = new EventRecodingLogger(_eventQueue);
            return logger;
        }

        public void ClearEvent() {
            while (_eventQueue.Count > 0) {
                _eventQueue.Dequeue().Recycle();
            }
        }
    }
}